package com.yswl.yeeduo.ui.bean;

import java.io.Serializable;
import java.lang.reflect.Type;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.json.JSONArray;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.reflect.TypeToken;
import com.yswl.yeeduo.ui.utils.JsonUtil;

/**
 *  app 活动实体类
 * @author Administrator
 *
 */
public class ActiviteDetailBean implements Serializable {
	
	/**
	 *    "index": 9,
                "jumpUrl": "http://wechat.lifedoo.cn/jump/s?q=1-1444891327000-IyN5ZWR1byMjNTYxZTg1YmFiOTU2N2RkYTRjOGI0OTI4IyN5ZWR1byMjaHR0cCUzQSUyRiUyRm1wLndlaXhpbi5xcS5jb20lMkZzJTNGX19iaXolM0RNekl3TnpBMU5qTTFOQSUzRCUzRCUyNm1pZCUzRDIxMDczNDExMSUyNmlkeCUzRDElMjZzbiUzRDQyMjUwMzI3ZTczNTk1YzFhODEwZjc4NzRiMTU1MzQxJTIzcmQ=",
                "title": "为什么跟越亲的人越没耐心？",
                "activeId": "561e85bab9567dda4c8b4928",
                "describe": "　(为保证收益，请下载APP进行分享）很多人对亲人发了脾气，事后很懊恼，可下次还会如此。",
                "coverImg": "http://s.lifedoo.cn:8088/M00/00/03/CqgtmFYehZ2AX2AIAAV4dQZ28UQ708.png",
                "url": "http://mp.weixin.qq.com/s?__biz=MzIwNzA1NjM1NA==&mid=210734111&idx=1&sn=42250327e73595c1a810f7874b155341#rd",
                "startTime": "2015-10-15 07:00:00",
                "endTime": "2015-10-16 07:00:00",
                "specialNote": "分享到朋友圈可获得随机奖励（截至10-16 07:00）",
                "specialNum": "",
                "readReward": "(APP专享）朋友圈一人阅读奖励0.02元",
                "flag": false,
                "agentName": "一点",
                "logo": "http://s.lifedoo.cn:8088/M00/00/01/CqgtmFXtxMCAMAjAAABB0ZmobAM170.jpg",
                "redflag": true
	 */
	private static final long serialVersionUID = -2410678216806938163L;
	public int index;
	public String jumpUrl;
	public String title;
	public String activeId;
	public String describe;
	public String coverImg;
	public String url;
//	public String pushType;
	public String startTime;
	public String endTime;
	public String specialNote;
	public String specialNum;//剩余阅读份数
	public String readReward;//阅读奖励文案
	public boolean flag;//是否已经分享
//	public boolean dodge;//是否显示提现按钮
	public String agentName;//app名称
	public String logo;//applogo
	public boolean redflag;//是否该文字红包是否有
	public String OrderMoney;//"money":"0.00"自己分享拿到的钱
//	public String activeMoney;// 带到排行版的特殊奖励的钱
	
	
	
	public static List<ActiviteDetailBean> jsonToList(JSONArray objarray) {
		Gson gson = new GsonBuilder().registerTypeAdapter(Date.class,  new JsonDeserializer<Date>() {
			public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
				SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				String dateStr = json.getAsString();
				try {
					return format.parse(dateStr);
				} catch (ParseException e) {
					e.printStackTrace();
				}
				return null;
			}
		}).setDateFormat("yyyy-MM-dd HH:mm:ss").create();
		Type listum = new TypeToken<ArrayList<ActiviteDetailBean>>() {}.getType();
		List<ActiviteDetailBean> result = gson.fromJson(objarray.toString(), listum);
		return result;
	}
	
	
	public static List<ActiviteDetailBean> json2List(String objarray) {
		List<ActiviteDetailBean> listBean ;
		Gson gson = new Gson();
		java.lang.reflect.Type type = new com.google.gson.reflect.TypeToken<ArrayList<ActiviteDetailBean>>() {
		}.getType();
		listBean = gson.fromJson(objarray, type);
		return listBean;
	}
	
	
	public static ActiviteDetailBean getBean(String jsonString) {
//		return (ActiviteDetailBean2) JsonUtil.jsonToBean(jsonString, ActiviteDetailBean2.class);
		return JsonUtil.json2Object(jsonString, ActiviteDetailBean.class);
	}

	
}
